﻿#region 文件信息

/*----------------------------------------------------------------
//
// 文件名称：
// 文件功能描述：
// 设计要求：
//
// 文 件 名：    FirstColumn
// 创建者：      杨程
// 创建日期：	    2022/11/22 10:13:45

//----------------------------------------------------------------*/

#endregion

namespace Vampirewal.Core.WPF.Theme;

/// <summary>
/// 首列
/// </summary>
public abstract class FirstColumn : DependencyObject
{
    /// <summary>
    /// 首列列头
    /// </summary>
    public string HeaderDisplayValue { get; protected set; }

    /// <summary>
    /// 是否有复选框
    /// </summary>
    public bool HasCheckBox { get; set; }

    #region 样式

    /// <summary>
    /// 列宽
    /// </summary>
    public double HeaderWidth { get; set; } = 100d;

    /// <summary>
    /// 纵向对齐方式
    /// </summary>
    public VerticalAlignment VerticalAlignment { get; set; } = VerticalAlignment.Center;

    /// <summary>
    /// 横向对齐方式
    /// </summary>
    public HorizontalAlignment HorizontalAlignment { get; set; } = HorizontalAlignment.Left;

    /// <summary>
    /// 文字颜色
    /// </summary>
    public Brush Foreground { get; set; } = Brushes.Black;

    #endregion
}

/// <summary>
/// 自动序号首列
/// </summary>
public class AutoCodeFirstColumn : FirstColumn
{
    public AutoCodeFirstColumn()
    {
        base.HeaderDisplayValue = "序号";
    }

    /// <summary>
    /// 标题
    /// </summary>
    public string FirstColumnHeader
    {
        get
        {
            return base.HeaderDisplayValue;
        }
    }

    /// <summary>
    /// 是否启用自动编号
    /// </summary>
    public bool UseAutoCode { get; set; } = true;
}

/// <summary>
/// 自定义首列
/// </summary>
public class CustromFirstColumn : FirstColumn
{
    #region SourceUpdate触发

    public ICommand FirstColumnSourceUpdateCommand
    {
        get { return (ICommand)GetValue(FirstColumnSourceUpdateCommandProperty); }
        set { SetValue(FirstColumnSourceUpdateCommandProperty, value); }
    }

    // Using a DependencyProperty as the backing store for FirstColumnSourceUpdateCommand.  This enables animation, styling, binding, etc...
    public static readonly DependencyProperty FirstColumnSourceUpdateCommandProperty =
        DependencyProperty.Register("FirstColumnSourceUpdateCommand", typeof(ICommand), typeof(CustromFirstColumn), new PropertyMetadata(null));

    #endregion

    public string FirstColumnHeader
    {
        get
        {
            return base.HeaderDisplayValue;
        }
        set
        {
            base.HeaderDisplayValue = value;
        }
    }

    /// <summary>
    /// 首列绑定的属性，以文字形式展示
    /// </summary>
    public string FirstColumnBindingPath { get; set; }

    /// <summary>
    /// 首列转换器
    /// </summary>
    public IValueConverter Converter { get; set; }

    /// <summary>
    /// 是否为只读
    /// </summary>
    public bool IsReadOnly { get; set; } = true;

    /// <summary>
    /// 是否只能编辑最明细项
    /// </summary>
    public bool JustEditDetailItem { get; set; }
}